package com.example.mvvmkotlin

import android.os.Bundle
import androidx.appcompat.app.AppCompatActivity
import com.blankj.utilcode.util.FragmentUtils
import com.example.mvvmkotlin.databinding.ActivityReplaceBinding

class ReplaceActivity : AppCompatActivity() {
    private lateinit var binding: ActivityReplaceBinding
    private val testFrag = TestFragment.newInstance()
    private val logFrag = LoginFragment.newInstance()
    var isRep = false
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        binding = ActivityReplaceBinding.inflate(layoutInflater)
        setContentView(binding.root)
        FragmentUtils.add(supportFragmentManager, testFrag, R.id.fragment)
        binding.btnReplace.setOnClickListener {
            if (isRep) {
                FragmentUtils.replace(logFrag, testFrag)
                isRep = false
            } else {
                FragmentUtils.replace(testFrag, logFrag)
                isRep = true
            }

        }

    }


}
